home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / lib / yotpin / src / fdline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-01  |  2.7 KB  |  122 lines

  1. /*
  2. *    Yamana's Otomeza Plug-in Tool
  3. *        かすれ線
  4. *    
  5. *    1995.08.01    かすれペン
  6. *    1995.08.13    逆方向サポート
  7. *    1995.08.27    線指定に改悪(^^;)
  8. *    
  9. *    問題点
  10. *    ・ペンよりかなり使いにくい
  11. *      仕方のないところか・・・
  12. *    
  13. */
  14. #include    "otome_pi.h"
  15. #include    "my_hatch.h"
  16.  
  17. #define    MAXPAT    (HATCH_MAX/4)        /* ハッチング最大   */
  18. #define    MAXVAL    (HATCH_MAX/4)        /* かすれ度合い最大 */
  19.  
  20. const char longname[] = "EFFECT: かすれ線";
  21. int            cnfg_max = 3;
  22. PI_CNFG        cnfg[] = {
  23.                 {"ペンの濃さ  →淡"    , 0,  MAXPAT-1,          0,         0    },
  24. //                {"かすれやすさ→淡"    , 1,  MAXVAL-1,MAXVAL/2,  MAXVAL/2    },
  25.                 {"ペンの大きさ"        , 1,        32,         16,        16    },
  26.                 {"濃淡逆転"            , 0,         1,          0,         0    },
  27.             };
  28.  
  29. #define    USE_ENV        PI_SET_ENV
  30. #define    USE_TYPE    PI_DRAW_LINE
  31. #define    USE_PEN        PI_USER_PEN
  32.  
  33. #include    "otome_pi.c"
  34.  
  35. /*******************************************************/
  36.  
  37. int APL_exec()
  38. {
  39.     int     pat,val,size,mode;
  40.     int     x,y,ox,oy;
  41.     int     rsin,rcos;
  42.     int     l,len, lstep,pstep;
  43.     int     hpat,minpat;
  44.     LINE    connect;
  45.     FRAME    fr;
  46.     
  47.     pat  = cnfg[0].val * 4 ;
  48. //    val  = (MAXVAL-cnfg[1].val)/2;    if( val==0 )    val = 1;
  49.     size = cnfg[1].val;
  50.     mode = cnfg[2].val;
  51.     
  52.     hpat = HATCH_MAX - pat ;
  53.     if( mode )
  54.     {    minpat    = pat;
  55.         pat     = HATCH_MAX;
  56.     }
  57.     
  58.     memcpy( &fr, g_para+2, 2*4 );
  59.     
  60.     x = (fr.lupx - fr.rdwx);
  61.     y = (fr.lupy - fr.rdwy);
  62.     len  = sqrt( x*x + y*y );
  63.     if( len == 0 || hpat == 0 )    return ERROR;
  64.     
  65.     rsin = -y*256 / len;
  66.     rcos = -x*256 / len;
  67.     
  68.     if( len > hpat )
  69.     {    lstep = len/hpat;
  70.         pstep = 1;
  71.     }else
  72.     {    lstep = 1;
  73.         pstep = hpat/len;
  74.     }
  75.     
  76.     EGB_mask        ( EgbPtr, EGB_MASK_OFF );
  77.     EGB_writePage    ( EgbPtr, PI_PAGE );
  78.     EGB_pen            ( EgbPtr, 0  );        /* 丸 */
  79.     EGB_penSize        ( EgbPtr, size );
  80.     EGB_paintMode    ( EgbPtr, EGB_PAINT_HATCHF );
  81.     EGB_color        ( EgbPtr, EGB_FORECOL, PI_FORECOL );
  82.     
  83.     connect.n=2;
  84.     ox=fr.lupx, oy=fr.lupy;
  85.     if( mode == 0 )    pat -= pstep;
  86.             else    pat += pstep;
  87.     
  88.     for( l=lstep; l<=len; l+=lstep )
  89.     {    
  90.         x = fr.lupx + (l * rcos >>8);
  91.         y = fr.lupy + (l * rsin >>8);
  92.         
  93.         if( mode == 0 )
  94.             if( pat+pstep< HATCH_MAX )    pat += pstep ;
  95.                                 else    pat =  HATCH_MAX;
  96.         else
  97.             if( pat-pstep>= minpat )    pat -= pstep ;
  98.                                 else    pat =  minpat;
  99.         
  100.         EGB_hatchingPattern( EgbPtr, EGB_FORECOL,
  101.                         HATCH_X, HATCH_Y, hatchData[pat] );
  102.         
  103.         connect.x0 = ox;    connect.y0 = oy;
  104.         connect.x1 = x ;    connect.y1 = y;
  105.         
  106.         EGB_connect( EgbPtr, &connect );
  107.         
  108.         ox=x, oy=y;
  109.         
  110.     }
  111.     
  112.     /* 乙女座が画面の再描画をする範囲を返す */
  113.     /* 全画面を設定して返すのが手っ取り早いが386機では差が出る */
  114.     ret_fr->lupx = ( (fr.lupx < fr.rdwx) ? fr.lupx:fr.rdwx )-32 ;
  115.     ret_fr->lupy = ( (fr.lupy < fr.rdwy) ? fr.lupy:fr.rdwy )-32 ;
  116.     ret_fr->rdwx = ( (fr.lupx > fr.rdwx) ? fr.lupx:fr.rdwx )+32 ;
  117.     ret_fr->rdwy = ( (fr.lupy > fr.rdwy) ? fr.lupy:fr.rdwy )+32 ;
  118.     
  119.     return NOERR;
  120. }
  121.  
  122.